package com.hwua.view;

import com.hwua.domain.Car;
import com.hwua.service.CarService;
import com.hwua.serviceimpl.CarServiceImpl;

import java.util.List;

/**
 * 租车界面
 * @author admin
 */
public class RentCarView extends AbstractView{
    private int num2;
    private String name;
    private String pwd;
    public RentCarView(int num2,String name,String pwd){
        this.num2=num2;
        this.name=name;
        this.pwd=pwd;
    }
    @Override
    public AbstractView showView() {
        CarService cs = new CarServiceImpl();
        List<Car> carList1 = cs.rentCarById(name, num2);
        if(!carList1.isEmpty()){
            System.out.println("借车成功！租车信息如下：");
            System.out.println("=====================================租车信息==========================================");
            System.out.println("编号\t汽车名称\t\t日租金\t\t品牌\t\t类型\t\t备注\t\t\t借车时间");
            for (Car car : carList1) {
                System.out.println(car.getRecordId()+"\t\t"+car.getCarName()+"\t\t\t"+car.getDailyRent()+
                        "\t\t"+car.getBrand()+"\t\t"+car.getType()+"\t\t"+car.getCarRemark()
                        + "\t\t"+car.getRentTime());
            }
            nextView=new UserView(name,pwd);
        }
        return nextView;
    }
}
